package org.example.mvc_demo.controller;

import org.example.mvc_demo.model.UserInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

@RestController
@RequestMapping("/request")
public class requestController {
    @RequestMapping("/param1")
    public String param1(String name) {
        System.out.println("接收的参数为："+name);
        return "接收的参数为："+name;
    }

    @RequestMapping("/param2")
    public String param2(String userName, String password) {
        System.out.println("userName:"+userName+",password:"+password);
        return "userName:"+userName+",password:"+password;
    }

    @RequestMapping("/param3")
    public String userInfo(UserInfo userInfo) {
        return "接受到的userInfo："+userInfo;
    }

    @RequestMapping("/param4")
    public String param4(@RequestParam(value = "userName",required = false) String name, String password) {
        System.out.println("userName:"+name+",password:"+password);
        return "userName:"+name+",password:"+password;
    }

    @RequestMapping("/param5")
    public String param5(String[] arrParram) {
        return "接受到的arrParram："+ Arrays.toString(arrParram);
    }

    @RequestMapping("/param5")
    public String param6(String[] arrParram) {
        return "接受到的arrParram："+ Arrays.toString(arrParram);
    }

}
